package com.monitor.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpAdvertisementCheckMapper;
import com.monitor.dao.ErpAdvertisementMapper;
import com.monitor.entity.ErpAdvertisement;
import com.monitor.service.ErpAdvertisementService;
import com.monitor.util.Result;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 广告审核后表 服务实现类
 * </p>
 *
 * @author LX
 * @since 2018-09-25
 */
@Service
@Transactional
public class ErpAdvertisementServiceImpl extends ServiceImpl<ErpAdvertisementMapper, ErpAdvertisement> implements ErpAdvertisementService {
	@Resource
	private ErpAdvertisementMapper erpAdvertisementMapper;
	
	@Resource
	private ErpAdvertisementCheckMapper erpAdvertisementCheckMapper;

	@Override
	public Result<Integer> editShow(int min) {
		// TODO Auto-generated method stub
		try {
			int count=erpAdvertisementMapper.editShow(min);
			count+=erpAdvertisementCheckMapper.editShow(min);
			return new Result<Integer>(count, 1);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return new Result<>(1, e.getMessage());
		}
	}

	@Override
	public Result<Integer> examine(int id, String time, String states,String name) {
		// TODO Auto-generated method stub
		try {
			ErpAdvertisement adv=erpAdvertisementMapper.selectById(id);
			adv.setCheckTime(time);
			adv.setCheckPeople(name);
			adv.setCheckState(states);
			int count=erpAdvertisementMapper.updateAllColumnById(adv);
			return new Result<Integer>(count, 1);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return new Result<>(1, e.getMessage());
		}
	}
	
	
}
